import 'package:dio/dio.dart';
import 'package:flutter/widgets.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_style.dart';

extension StringExtension on String {
  int get characterCount {
    return this.length;
  }
  defValue(String str){
    if(this.isEmpty)return str;
    return this;
  }
}

extension ObjExtension on dynamic {
  get asString => this.toString();
}

extension MapExtension on Map<String, dynamic> {
  get asForm => FormData.fromMap(this);
}

extension ListExtension on List {
  LContainer listView(Widget Function(  int index) itemBuilder) {
    return LContainer(
        child: ListView.builder(
          itemCount: this.length,
            padding: EdgeInsets.zero, itemBuilder: (context, position) {
            return itemBuilder(  position);
        }));
  }
}
extension LetExtension<T> on T? {
  R? let<R>(R? Function(T) block) {
    return this == null ? null : block(this!);
  }
}

